﻿<%@ Page Title="FXSwap交易資料" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="FXSwapTrade.aspx.cs" Inherits="FXSwapTrade"%>

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <style type="text/css">
        .style4
        {
            color: #FF0000;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <p>
        資料日期：<asp:TextBox ID="reportDate" runat="server"></asp:TextBox>
    &nbsp;
        <asp:Button ID="queryBtn" runat="server" Text="取得交易資料" 
            onclick="queryBtn_Click" />
    &nbsp;<asp:Button ID="exportToCsv" runat="server" onclick="exportToCsv_Click" 
            Text="匯出到CSV" />
    </p>
    <p>
        <asp:GridView ID="GridView1" runat="server" 
            AutoGenerateColumns="False" DataSourceID="SqlDataSource1" CellPadding="4" 
            ForeColor="#333333" GridLines="None" 
            DataKeyNames="id" 
            ondatabound="GridView1_DataBound" PageSize="20">
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
            <Columns>
                <asp:BoundField DataField="ProductType" HeaderText="ProductType" 
                    SortExpression="ProductType" />
                <asp:BoundField DataField="SequenceNo" HeaderText="SequenceNo" 
                    SortExpression="SequenceNo" />
                <asp:BoundField DataField="BankCode" HeaderText="BankCode" 
                    SortExpression="BankCode" />
                <asp:BoundField DataField="BankType" HeaderText="BankType" 
                    SortExpression="BankType" />
                <asp:BoundField DataField="TransUnit" HeaderText="TransUnit" 
                    SortExpression="TransUnit" />
                <asp:BoundField DataField="CptyType" HeaderText="CptyType" 
                    SortExpression="CptyType" />
                <asp:BoundField DataField="CptyName" HeaderText="CptyName" 
                    SortExpression="CptyName" />
                <asp:BoundField DataField="CptyCode" HeaderText="CptyCode" 
                    SortExpression="CptyCode" />
                <asp:BoundField DataField="TransReason" HeaderText="TransReason" 
                    SortExpression="TransReason" />
                <asp:BoundField DataField="TradeDate" HeaderText="TradeDate" 
                    SortExpression="TradeDate" DataFormatString="{0:d}" />
                <asp:BoundField DataField="EffectiveDate" HeaderText="EffectiveDate" 
                    SortExpression="EffectiveDate" DataFormatString="{0:d}" />
                <asp:BoundField DataField="MaturityDate" HeaderText="MaturityDate" 
                    SortExpression="MaturityDate" DataFormatString="{0:d}" />
                <asp:BoundField DataField="BuyCcy" HeaderText="BuyCcy" 
                    SortExpression="BuyCcy" />
                <asp:BoundField DataField="BuyNotional" HeaderText="BuyNotional" 
                    SortExpression="BuyNotional" />
                <asp:BoundField DataField="SellCcy" HeaderText="SellCcy" 
                    SortExpression="SellCcy" />
                <asp:BoundField DataField="SellNotional" HeaderText="SellNotional" 
                    SortExpression="SellNotional" />
                <asp:BoundField DataField="CcyPair" 
                    HeaderText="CcyPair" SortExpression="CcyPair" />
                <asp:BoundField DataField="NDFSettleCcy" HeaderText="NDFSettleCcy" 
                    SortExpression="NDFSettleCcy" />
                <asp:BoundField DataField="SwapPoint" HeaderText="SwapPoint" 
                    SortExpression="SwapPoint" />
            </Columns>
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <EmptyDataTemplate>
                執行結果： 
                <br />
                <span class="style4">您輸入的資料日期，目前查無符合資料！</span>
            </EmptyDataTemplate>
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <EditRowStyle BackColor="#999999" />
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:FEIBConnectionString %>" 
            
            
            SelectCommand="SELECT * FROM [TR_FormatA_FX] WHERE (([TradeDate] = @TradeDate) AND ([TradeType] = @TradeType))" 
            DeleteCommand="DELETE FROM [TR_FormatA_FX] WHERE [id] = @id" 
            InsertCommand="INSERT INTO [TR_FormatA_FX] ([ProductType], [SequenceNo], [BankCode], [BankType], [TransUnit], [CptyType], [CptyName], [CptyCode], [TransReason], [TradeDate], [EffectiveDate], [MaturityDate], [BuyCcy], [BuyNotional], [SellCcy], [SellNotional], [CcyPair], [NDFSettleCcy], [SwapPoint], [TradeType]) VALUES (@ProductType, @SequenceNo, @BankCode, @BankType, @TransUnit, @CptyType, @CptyName, @CptyCode, @TransReason, @TradeDate, @EffectiveDate, @MaturityDate, @BuyCcy, @BuyNotional, @SellCcy, @SellNotional, @CcyPair, @NDFSettleCcy, @SwapPoint, @TradeType)" 
            
            UpdateCommand="UPDATE [TR_FormatA_FX] SET [ProductType] = @ProductType, [SequenceNo] = @SequenceNo, [BankCode] = @BankCode, [BankType] = @BankType, [TransUnit] = @TransUnit, [CptyType] = @CptyType, [CptyName] = @CptyName, [CptyCode] = @CptyCode, [TransReason] = @TransReason, [TradeDate] = @TradeDate, [EffectiveDate] = @EffectiveDate, [MaturityDate] = @MaturityDate, [BuyCcy] = @BuyCcy, [BuyNotional] = @BuyNotional, [SellCcy] = @SellCcy, [SellNotional] = @SellNotional, [CcyPair] = @CcyPair, [NDFSettleCcy] = @NDFSettleCcy, [SwapPoint] = @SwapPoint, [TradeType] = @TradeType WHERE [id] = @id">
            <SelectParameters>
                <asp:ControlParameter ControlID="reportDate" Name="TradeDate" 
                    PropertyName="Text" Type="DateTime" />
                <asp:Parameter DefaultValue="FXSWAP" Name="TradeType" Type="String" />
            </SelectParameters>
            <DeleteParameters>
                <asp:Parameter Name="id" Type="Int64" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="ProductType" Type="String" />
                <asp:Parameter Name="SequenceNo" Type="String" />
                <asp:Parameter Name="BankCode" Type="String" />
                <asp:Parameter Name="BankType" Type="String" />
                <asp:Parameter Name="TransUnit" Type="String" />
                <asp:Parameter Name="CptyType" Type="String" />
                <asp:Parameter Name="CptyName" Type="String" />
                <asp:Parameter Name="CptyCode" Type="String" />
                <asp:Parameter Name="TransReason" Type="String" />
                <asp:Parameter Name="TradeDate" Type="DateTime" />
                <asp:Parameter Name="EffectiveDate" Type="DateTime" />
                <asp:Parameter Name="MaturityDate" Type="DateTime" />
                <asp:Parameter Name="BuyCcy" Type="String" />
                <asp:Parameter Name="BuyNotional" Type="Decimal" />
                <asp:Parameter Name="SellCcy" Type="String" />
                <asp:Parameter Name="SellNotional" Type="Decimal" />
                <asp:Parameter Name="CcyPair" Type="String" />
                <asp:Parameter Name="NDFSettleCcy" Type="String" />
                <asp:Parameter Name="SwapPoint" Type="Decimal" />
                <asp:Parameter Name="TradeType" Type="String" />
                <asp:Parameter Name="id" Type="Int64" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="ProductType" Type="String" />
                <asp:Parameter Name="SequenceNo" Type="String" />
                <asp:Parameter Name="BankCode" Type="String" />
                <asp:Parameter Name="BankType" Type="String" />
                <asp:Parameter Name="TransUnit" Type="String" />
                <asp:Parameter Name="CptyType" Type="String" />
                <asp:Parameter Name="CptyName" Type="String" />
                <asp:Parameter Name="CptyCode" Type="String" />
                <asp:Parameter Name="TransReason" Type="String" />
                <asp:Parameter Name="TradeDate" Type="DateTime" />
                <asp:Parameter Name="EffectiveDate" Type="DateTime" />
                <asp:Parameter Name="MaturityDate" Type="DateTime" />
                <asp:Parameter Name="BuyCcy" Type="String" />
                <asp:Parameter Name="BuyNotional" Type="Decimal" />
                <asp:Parameter Name="SellCcy" Type="String" />
                <asp:Parameter Name="SellNotional" Type="Decimal" />
                <asp:Parameter Name="CcyPair" Type="String" />
                <asp:Parameter Name="NDFSettleCcy" Type="String" />
                <asp:Parameter Name="SwapPoint" Type="Decimal" />
                <asp:Parameter Name="TradeType" Type="String" />
            </InsertParameters>
        </asp:SqlDataSource>
&nbsp;<asp:CalendarExtender ID="reportDate_CalendarExtender" runat="server" 
            Enabled="True" Format="yyyy/MM/dd" TargetControlID="reportDate">
        </asp:CalendarExtender>
    </p>
</asp:Content>

